let uu = document.querySelector('.uu')
let foot = document.querySelector('.footer1>div>b:nth-of-type(3)')
let span = document.querySelector('span')
fetch('http://chst.vip:1234/api/getinlanddiscount')
    .then(body => body.json())
    .then(res => {
        console.log(res)
        render(res.result, uu)
    })
function render(data, el) {
    console.log(data, el)
    let domStr = ''
    data.forEach(item => {
        console.log(item.productImg)
        domStr += `<li ><img src="" alt="图片" productid=${item.productId}><p>${item.productName}</p>
            </li>
            `
        el.innerHTML = domStr
    })
}
uu.onclick = function (e) {
    console.log(e.target)
    if (e.target.localName == 'img') {
        let _this = e.target
        console.log(_this)
        let id = _this.getAttribute('productid')
        console.log(id);
        location.href = "./../html/guoneixiangqing.html?productid=" + id
        id = Number(id)
        console.log(id)
    }
}
span.onclick = function () {
    location.href = "../index.html"
}
foot.onclick = function () {
    location.href = "../index.html"
}